<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('leaves', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id')->index()->comment('申请人ID');
            $table->unsignedBigInteger('role_id')->index()->comment('部门ID');
            $table->unsignedBigInteger('project_id')->index();
            $table->string('type')->comment('请假类型');
            $table->string('position')->default('/')->comment('职务');
            $table->dateTime('start_time')->comment('开始时间');
            $table->dateTime('end_time')->comment('结束时间');
            $table->decimal('duration', 5, 2)->default(0)->comment('时长（天）');
            $table->string('reason')->default('/')->comment('请假原因');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('leaves');
    }
};
